﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CashShop.Bussiness1;


namespace CashShop1
{
    public partial class Form1 : Form
    {

        private CashFacade1 cf = new CashFacade1();

        //创建一个计算总价的变量
        private decimal totalPrice = 0.00M;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load_1(object sender, EventArgs e)
        {
            //读取XMl文件，获取下拉菜单
            cbx.DataSource = cf.GetCashAcceptTypeList();
            cbx.SelectedIndex = 0;

        }

        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btConfirm_Click(object sender, EventArgs e)
        {
            var total = 0.00M;
            //传值下拉选择活动和原价，计算实际收费

            total=cf.GetTotalPrice(cbx.SelectedItem.ToString(),
                Convert.ToDecimal(Price.Text) * Convert.ToDecimal(Num.Text)); 

            totalPrice += total;
            lbList.Items.Add("单价：" + Price.Text+"￥" + "数量：" + Num.Text + " " + cbx.SelectedItem
                + " 合计:" + total);
            labReturn.Text = totalPrice.ToString("C");
        }
        /// <summary>
        /// 重置按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btReset_Click(object sender, EventArgs e)
        {
            totalPrice = 0.00M;
            Num.Text = "";
            Price.Text = "";
            lbList.Items.Clear();
            labReturn.Text = "";
        }
    }
}
